package com.campus.merchant.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.campus.merchant.entity.Category;
import com.campus.merchant.mapper.CategoryMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商户分类表 服务实现类
 * </p>
 *
 * @author ZhaoYuJie
 * @since 2025-04-18
 */
@Service
public class CategoryService extends ServiceImpl<CategoryMapper, Category> {

    /**
     * 获取所有启用的分类列表
     * @return 分类列表
     */
    public List<Category> getEnabledCategories() {
        LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Category::getStatus, 1)
                   .orderByAsc(Category::getSort)
                   .orderByAsc(Category::getId);
        return list(queryWrapper);
    }
}
